package com.trust.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.trust.agri.util.BeanUtil;
import com.trust.entity.MaterialInput;
import com.trust.entity.result.MaterialInputDropDownResult;
import com.trust.mapper.MaterialInputMapper;
import com.trust.service.MaterialInputService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class MaterialInputServiceImpl extends ServiceImpl<MaterialInputMapper, MaterialInput> implements MaterialInputService {


    @Override
    public List<MaterialInputDropDownResult> dropDown() {
        LambdaQueryWrapper<MaterialInput> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MaterialInput::getEnabled, 1);
        wrapper.orderByDesc(MaterialInput::getId);
        List<MaterialInput> list = this.list(wrapper);
        return BeanUtil.sourceList2targetList(list, MaterialInputDropDownResult.class);
    }
}
